package com.proxy.demo04;


import com.proxy.demo02.IGamePlayer;

public class GamePlayerProxy implements IGamePlayer {
    // 重点是代理角色内部创建了被代理对象角色,也就是说玩家已经不能自己创建,必须由代理类创建
    private IGamePlayer iGamePlayer = null;

    public GamePlayerProxy(String name){
        // 代理创建具体被代理玩家,玩家内部引用了代理
        try {
            iGamePlayer = new GamePlayer(this, name);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void login(String userName, String password) {
        this.iGamePlayer.login(userName, password);
    }

    @Override
    public void killBoss() {
        this.iGamePlayer.killBoss();
    }

    @Override
    public void upgrade() {
        this.iGamePlayer.upgrade();
    }
}
